<template>
	<view class="data-stat"
		:style="{ background: `url(${assetsPath}b06d5082b279372c5e22b6c40432135f7fdca194.png) left top/100% calc(${navBarHeight}px + 280rpx) no-repeat` }">
		<nav-bar title="产品中心" :color="navBarColor" :bg="navBarBg" />

		<view class="address">
			<view class="flex-space-between">
				<view class="flex-align">
					<van-image v-if="itemChooselist.venue_thumb != ''" width="74rpx" height="74rpx" radius="2"
						style="margin-right: 10rpx;" :src="itemChooselist.venue_thumb" />
					<van-image v-else width="74rpx" height="74rpx" radius="10rpx" fit="cover" style="margin-right: 10rpx;" src="https://img.yzcdn.cn/vant/cat.jpeg" />
					<view>
						<view class="address-name">{{itemChooselist.venue_name}}</view>
						<view class="address-desc">地址:{{itemChooselist.address}}</view>
					</view>
				</view>
				<view class="exchange flex-center flex-column " @click="show_no">
					<van-icon name="exchange" size="16" />
					切换
				</view>
			</view>
		</view>

		<view class="list-items_1-0">
			<view class="image-text_9-0">
				<image
					src="https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/img/7a854b2c3eb388535a942461ca5a3ed20acbe67b.png"
					class="icon_9-0"></image>
				<text lines="1" class="text-group_1-0">预约票管理</text>
			</view>
			<image
				src="https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/img/9804337222fa36530d79050e73bb46f1c51a6c90.png"
				class="image_1-0"></image>
			<view class="text-wrapper_16-0">
				<text lines="1" class="text_30-0">1</text>
				<text lines="1" class="text_31-0">审批中</text>
			</view>
			<view class="text-wrapper_17-0">
				<text lines="1" class="text_32-0">1</text>
				<text lines="1" class="text_33-0">已上架</text>
			</view>
			<view class="text-wrapper_18-0">
				<text lines="1" class="text_34-0">1</text>
				<text lines="1" class="text_35-0">已下架</text>
			</view>
			<image
				src="https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/img/10f85293a318f2f54f41856caef4d6001e0224f6.png"
				class="icon_2-0"></image>
		</view>


		<van-popup closeable :show="show" round position="bottom" @close="showclose">
			<view class="good-box">
				<view class="title">
					切换场馆
				</view>
				<view class="good-list">
					<view class="good-item" v-for="(item,index) in venuelist" :key="index" @click="onChangelist(item)">
						<view class="flex-align">
							<van-image width="124rpx" height="124rpx" radius="10rpx" fit="cover"
								v-if="item.venue_thumb != ''" :src="item.venue_thumb" />
							<van-image v-else width="124rpx" height="124rpx" radius="10rpx" fit="cover"
								src="https://img.yzcdn.cn/vant/cat.jpeg" />
							<view class="info">
								<view class="name">{{item.venue_name}}</view>
								<view class="flex-align" v-if="item.project_list != ''">
									<view class="tag" v-if="item.project_list[0].name != ''">
										{{item.project_list[0].name}}
									</view>
									<view class="tag" v-if="item.project_list[1].name != '' && item.project_list[1]">
										{{item.project_list[1].name}}
									</view>
									<view class="tag" v-if="item.project_list[2].name != ''&& item.project_list[2]">
										{{item.project_list[2].name}}
									</view>
								</view>
								<view class="address">{{item.address}}</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</van-popup>
	</view>
</template>

<script>
	const personal = require("@/api/personal/index.js");
	import navbar from '@/mixins/navbar.js';

	export default {
		mixins: [navbar({
			navBarColor: '#fff'
		})],
		data() {
			return {
				navBarHeight: 0,
				assetsPath: this.$https.assetsPath,
				show: false,
				radio: '1',
				dates: [{
						label: '今日',
						value: '5'
					},
					{
						label: '本周',
						value: '6'
					},
					{
						label: '本月',
						value: '7'
					},
					{
						label: '本年',
						value: '8'
					},
				],
				dateActive: '5',
				opts: {
					"color": ['#635df7'],
					fontSize: 12,
					"xAxis": {
						axisLineColor: 'rgb(229,229,229)',
						"disableGrid": true,
						fontColor: 'rgb(153,153,153)',
						fontSize: 10,
					},
					"yAxis": {
						gridColor: 'rgb(229,229,229)',
						data: [{
							axisLine: false,
							fontColor: 'rgb(153,153,153)',
							fontSize: 10,
							title: '收入(元)'
						}],
						showTitle: true
					},
					"legend": {
						show: false
					},
					"extra": {
						"line": {
							"type": "straight",
							"width": 2
						},
					}
				},
				// 收入趋势
				chartData: {
					categories: [],
					series: [{
						name: "",
						data: [],
						pointShape: 'none',
						textColor: 'rgba(0,0,0,0)'
					}]
				},
				// 销售额分析总额
				pieOpts: {
					"title": {
						"name": "总额",
						"fontSize": 12,
						"color": "#b5b5b5"
					},
					"subtitle": {
						"name": "￥",
						"fontSize": 12,
						"color": "#b5b5b5"
					},
					// color: ['rgb(230,148,148)', 'rgb(82,222,151)', 'rgb(241,201,176)', 'rgb(81,200,194)',
					// 	'rgb(241,237,153)', 'rgb(178,154,228)', 'rgb(245,225,153)', 'rgb(219,246,186)'
					// ],
					extra: {
						ring: {
							borderWidth: 1,
							ringWidth: 45,
							linearType: 'custom',
						}
					},
					legend: {
						position: 'right'
					},
					// dataLabel: false,
				},

				// 销售额分析
				pieChartData: {
					series: [{
						data: []
					}]
				},
				chartsDataRing1: {
					"series": [{
						"data": [{
							"name": "一班",
							"value": 50
						}, {
							"name": "二班",
							"value": 30
						}, {
							"name": "三班",
							"value": 20
						}, {
							"name": "四班",
							"value": 18
						}, {
							"name": "五班",
							"value": 8
						}]
					}]
				},
				// 销售额明细
				tableData: [],
				venuelist: [], //场馆列表
				itemChoose: {}, // 场馆数据
				itemChooselist: {}, // 场馆数据
				showlist: true,
				income: '',
				order_cnt: "",
				sum: "",
				sum1: "",
				sum2: "",
				sum3: "",
				nac: 5
			}
		},
		created() {
			const {
				navBarHeight
			} = getApp().globalData;
			this.navBarHeight = navBarHeight;

		},
		onLoad() {
			if (uni.getStorageSync("entry_name") == '') {
				uni.showToast({
					title: '请登录！',
					icon: 'exception',
					duration: 850
				});
				setTimeout(() => {
					uni.navigateTo({
						url: '/pages/my-center/my-center'
					})
				}, 1000);
			}
			var data = uni.getStorageSync("wqzdy");
			var items = JSON.parse(data)
			this.venuelist = items
			this.itemChooselist = this.venuelist[0]
			this.finance()
		},
		methods: {
			async finance() {
				// uni.showLoading({
				// 	title: "加载中",
				// 	mask: true,
				// });
				let params = {
					venue_id: this.itemChooselist.id,
					sourceTab: this.nac
				};
				let res = await personal.finance(params);
				if (res.code == 1) {
					this.chartData = res.data.chartData //收入趋势
					this.pieChartData = res.data.pieChartData //销售额分析
					this.order_cnt = res.data.incomeInfo.order_cnt //订单号
					this.income = res.data.incomeInfo.income //收入
					this.tableData = res.data.billingList //销售额明细
					this.pieOpts.subtitle.name = res.data.pieChartData.total_income
					this.sum = res.data.billingList.reduce((acc, val) => acc + parseFloat(val.goods_number), 0)
					this.sum1 = res.data.billingList.reduce((acc, val) => acc + parseFloat(val.should_income), 0)
					this.sum2 = res.data.billingList.reduce((acc, val) => acc + parseFloat(val.act_income), 0)
					this.sum3 = res.data.billingList.reduce((acc, val) => acc + parseFloat(val.discount_amount), 0)
					// uni.hideLoading();
				}
			},
			onClick({
				url
			}) {
				uni.navigateTo({
					url
				})
			},
			// 选择场馆
			onChange(e) {
				let that = this
				let i = e.detail
				const item = this.venuelist[i]
				if (item) {
					this.itemChoose = item
					this.venuelist[i].checked = true
				} else {
					this.itemChoose = {}
				}
			},
			onChangelist(item) {
				this.itemChoose = item
				this.itemChooselist = this.itemChoose
				this.show = false
				this.showlist = true
				this.nac = this.nac
				this.dateActive = this.dateActive
				this.finance()
			},
			// 确认按钮
			queren() {
				this.itemChooselist = this.itemChoose
				this.show = false
				this.showlist = true
				this.nac = this.nac
				this.dateActive = this.dateActive
				this.finance()
			},
			dataslist(item) {
				this.chartData = [] //收入趋势
				this.pieChartData = [] //销售额分析
				this.order_cnt = [] //订单号
				this.income = [] //收入
				this.tableData = [] //销售额明细
				this.sum = ''
				this.sum1 = ''
				this.sum2 = ''
				this.sum3 = ''
				this.nac = item.value
				this.dateActive = item.value
				this.finance()
			},
			show_no() {
				this.show = true
				this.showlist = false
			},
			showclose() {
				this.show = false
				this.showlist = true
			}
		},

	}
</script>

<style lang="scss" scoped>
	.data-stat {
		min-height: 100vh;
		padding: 0 36rpx 50rpx;
		background-color: #e1e1e1;

		.address {
			color: #fff;
			padding-top: 20rpx;
			padding-right: 30rpx;
			height: 70rpx;

			&-name {
				font-size: 32rpx;
				font-weight: 700;
				line-height: 34rpx;
			}

			&-desc {
				margin-top: 18rpx;
				font-size: 22rpx;
				line-height: 22rpx;
			}

			.exchange {
				width: 100rpx;
				height: 100rpx;
				border-radius: 50%;
				background-color: rgba(0, 0, 0, 0.2);
				color: rgb(234, 248, 248);
				font-size: 24rpx;
			}
		}


		.title {
			color: #000;
			font-size: 30rpx;
			font-weight: 700;
			margin-top: 40rpx;
		}

		.classify {
			.box {
				margin-top: 40rpx;
			}
		}

		/deep/ .good-box {
			height: 60vh;
			padding: 0px 30rpx;
			display: flex;
			flex-direction: column;

			.van-radio__label {
				line-height: inherit;
			}

			.good-list {
				flex: 1;
				height: 0;
				overflow: auto;

				.good-item {
					margin-top: 30rpx;

					.info {
						margin-left: 25rpx;

						.name {
							color: rgb(51, 51, 51);
							font-size: 30rpx;
							font-weight: 500;
							margin-bottom: 10rpx;
						}


						.tag {
							color: rgb(4, 179, 90);
							font-size: 24rpx;
							font-weight: 500;
							padding: 0px 10rpx;
							margin-right: 20rpx;
							background-color: rgba(4, 179, 90, 0.2);
							border-radius: 4rpx;

							&:nth-of-type(2) {
								color: rgb(236, 70, 246);
								background-color: rgba(236, 70, 246, 0.2);
							}
						}

						.address {
							margin-top: 10rpx;
							color: rgb(136, 136, 136);
							font-size: 22rpx;
						}
					}

				}
			}

			.footer {
				padding: 20rpx 0;
				background-color: rgb(255, 255, 255);

				.btn {
					color: rgb(255, 255, 255);
					font-size: 30rpx;
					font-weight: 700;
					padding: 20rpx 0;
					text-align: center;
					background-image: linear-gradient(0deg, rgb(99, 93, 247) 0%, rgb(165, 173, 246) 100%);
					border-radius: 60rpx;
				}
			}
		}

		.list-items_1-0 {
			background-color: rgba(255, 255, 255, 1.000000);
			border-radius: 10rpx;
			width: 690rpx;
			height: 180rpx;
			margin-bottom: 20rpx;
			margin-top: 50rpx;
			flex-direction: row;
			display: flex;
		}

		.image-text_9-0 {
			width: 119rpx;
			height: 77rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			margin: 49rpx 0 0 33rpx;
		}

		.icon_9-0 {
			width: 40rpx;
			height: 40rpx;
			margin-left: 39rpx;
		}

		.text-group_1-0 {
			width: 119rpx;
			height: 23rpx;
			overflow-wrap: break-word;
			color: rgba(51, 51, 51, 1);
			font-size: 24rpx;
			font-family: PingFang-SC-Medium;
			font-weight: 500;
			text-align: left;
			white-space: nowrap;
			line-height: 34rpx;
			margin-top: 14rpx;
		}

		.image_1-0 {
			width: 1rpx;
			height: 90rpx;
			margin: 45rpx 0 0 32rpx;
		}

		.text-wrapper_16-0 {
			width: 68rpx;
			height: 68rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			margin: 56rpx 0 0 64rpx;
		}

		.text_30-0 {
			width: 9rpx;
			height: 22rpx;
			overflow-wrap: break-word;
			color: rgba(255, 65, 5, 1);
			font-size: 30rpx;
			font-family: DIN-Bold;
			font-weight: 700;
			text-align: left;
			white-space: nowrap;
			line-height: 34rpx;
			margin-left: 29rpx;
		}

		.text_31-0 {
			width: 68rpx;
			height: 23rpx;
			overflow-wrap: break-word;
			color: rgba(190, 190, 190, 1);
			font-size: 24rpx;
			font-family: PingFang-SC-Medium;
			font-weight: 500;
			text-align: left;
			white-space: nowrap;
			line-height: 34rpx;
			margin-top: 23rpx;
		}

		.text-wrapper_17-0 {
			width: 69rpx;
			height: 67rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			margin: 56rpx 0 0 61rpx;
		}

		.text_32-0 {
			width: 9rpx;
			height: 22rpx;
			overflow-wrap: break-word;
			color: rgba(51, 51, 51, 1);
			font-size: 30rpx;
			font-family: DIN-Bold;
			font-weight: 700;
			text-align: left;
			white-space: nowrap;
			line-height: 34rpx;
			margin-left: 29rpx;
		}

		.text_33-0 {
			width: 69rpx;
			height: 22rpx;
			overflow-wrap: break-word;
			color: rgba(190, 190, 190, 1);
			font-size: 24rpx;
			font-family: PingFang-SC-Medium;
			font-weight: 500;
			text-align: left;
			white-space: nowrap;
			line-height: 34rpx;
			margin-top: 23rpx;
		}

		.text-wrapper_18-0 {
			width: 69rpx;
			height: 68rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			margin: 56rpx 0 0 62rpx;
		}

		.text_34-0 {
			width: 9rpx;
			height: 22rpx;
			overflow-wrap: break-word;
			color: rgba(51, 51, 51, 1);
			font-size: 30rpx;
			font-family: DIN-Bold;
			font-weight: 700;
			text-align: left;
			white-space: nowrap;
			line-height: 34rpx;
			margin-left: 21rpx;
		}

		.text_35-0 {
			width: 69rpx;
			height: 23rpx;
			overflow-wrap: break-word;
			color: rgba(190, 190, 190, 1);
			font-size: 24rpx;
			font-family: PingFang-SC-Medium;
			font-weight: 500;
			text-align: left;
			white-space: nowrap;
			line-height: 34rpx;
			margin-top: 23rpx;
		}

		.icon_2-0 {
			width: 13rpx;
			height: 22rpx;
			margin: 79rpx 40rpx 0 59rpx;
		}
	}
</style>